capture log close
clear all
#delimit ;

log using RD.txt, text replace;

use RD.dta, clear;

sum pctover if pctover<0, d;
local med_below=r(p50);
sum pctover if pctover>=0, d;
local med_above=r(p50);

*Table 8;
rd L1kld pctover, covar(yr1997-yr2011) mbw(100); di "N = " e(N);
rd SL1kld pctover, covar(yr1997-yr2011) mbw(100); di "N = " e(N);
rd l_L1at pctover, covar(yr1997-yr2011) mbw(100); di "N = " e(N);
rd l_L1mktcap pctover, covar(yr1997-yr2011) mbw(100); di "N = " e(N);
rd L1firmreturn pctover, covar(yr1997-yr2011) mbw(100); di "N = " e(N);
rd l_L1totalcomp pctover, covar(yr1997-yr2011) mbw(100); di "N = " e(N);

*Table 9 Panel A;
rd SF1kld pctover if restype!=3, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1kld pctover if restype!=3, covar(yr1997-yr2011) mbw(75);  di "N = " e(N);
rd SF1kld pctover if restype!=3, covar(yr1997-yr2011) mbw(125);  di "N = " e(N);
rd SF1kld pctover if restype!=3, covar(yr1997-yr2011) mbw(50);  di "N = " e(N);
rd SF1kld pctover if restype!=3, covar(yr1997-yr2011) mbw(150);  di "N = " e(N);

*Table 9 Panel B;
rd SF1kld pctover if restype==3, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1kld pctover if restype==2, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1kld pctover if restype==4, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1kld pctover if restype==6, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1kld pctover if (restype==5 | restype==1), covar(yr1997-yr2011) mbw(100);  di "N = " e(N);

*Table 10;
rd SF1zkld pctover if restype!=3, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1hkld pctover if restype!=3, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1dmkld pctover if restype!=3, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
rd SF1kld pctover if restype!=3, covar(l_L1at L1ib l_L1mktcap w_L1mb w_L1tobinq yr1997-yr2011) mbw(100);  di "N = " e(N);

rd SF1kld pctover if restype!=3, z0(`med_below') covar(yr1997-yr2011) mbw(100); di "N = " e(N);
rd SF1kld pctover if restype!=3, z0(`med_above') covar(yr1997-yr2011) mbw(100); di "N = " e(N);
rd SF1eindex pctover if restype==4, covar(yr1997-yr2007) mbw(100);  di "N = " e(N);
rd SF1heindex pctover if restype==4, covar(yr1997-yr2011) mbw(100);  di "N = " e(N);
 

*Table 11 Panel A;
reg SF1kld passed i.year if restype!=3, vce(cluster anonymized_firmcode);
reg SF1kld passed i.year if restype!=3 & abs(pctover)<=10, vce(cluster anonymized_firmcode);
reg SF1kld passed i.year if restype!=3 & abs(pctover)<=5, vce(cluster anonymized_firmcode);
reg SF1kld passed i.year if restype!=3 & abs(pctover)<=3, vce(cluster anonymized_firmcode);
reg SF1kld passed i.year if restype!=3 & abs(pctover)<=1, vce(cluster anonymized_firmcode);

*Table 11 Panel B;
rd SF1xrd2Lat pctover if restype!=3, covar(yr1997-yr2011) bwidth(4.436) vce(cluster anonymized_firmcode);  di "N = " e(N);
rd SF1xad2Lat pctover if restype!=3, covar(yr1997-yr2011) bwidth(4.436) vce(cluster anonymized_firmcode);  di "N = " e(N);
rd SF1xrad2Lat pctover if restype!=3, covar(yr1997-yr2011) bwidth(4.436) vce(cluster anonymized_firmcode);  di "N = " e(N);
rd SF1xrd2Lat pctover if restype!=3, covar(yr1997-yr2011) mbw(100) vce(cluster anonymized_firmcode);  di "N = " e(N);
rd SF1xad2Lat pctover if restype!=3, covar(yr1997-yr2011) mbw(100) vce(cluster anonymized_firmcode);  di "N = " e(N);
rd SF1xrad2Lat pctover if restype!=3, covar(yr1997-yr2011) mbw(100) vce(cluster anonymized_firmcode);  di "N = " e(N);

*Figure 6;
hist pctover, freq width(2.5)
	xtitle("Voteshare % in excess of pass cutoff") 
	xline(0, lstyle(foreground))
	bfcolor(gray)
	bcolor(black)
	ylabel(, nogrid)
	graphregion(color(white))
	legend(off);
graph export Figure6.eps, replace;


*Figure 7;
reg SF1kld i.year if restype!=3;
predict SF1kld_yr_resid, residuals;
twoway 
(lpolyci SF1kld_yr_resid pctover if pctover<0 & pctover>=-10 & restype!=3, bwidth(4.436) k(tri) 
	level(90) deg(1) clwidth(medium) clcolor(black)) 
(lpolyci SF1kld_yr_resid pctover if pctover>=0 & pctover<=10 & restype!=3,  bwidth(4.436) k(tri) 
	level(90) deg(1) clwidth(medium) clcolor(black)),
legend(off) xline(0, lstyle(foreground))
ylabel(, nogrid)
graphregion(color(white)) 
xtitle("Voteshare % in excess of pass cutoff")
ytitle("KLD(t+1) - KLD(t)")
;
graph export Figure7.eps, replace;


log close;

